package com.example.paimengshop;

import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;

public class centerUnloginController implements Initializable {

    @FXML
    private Button exitButton;

    @FXML
    private Button collectionButton;

    @FXML
    private Button orderButton;

    @FXML
    private ImageView loginView;


    @Override
    public void initialize(URL url, ResourceBundle resourceBundle) {

        exitButton.setVisible(false);
        collectionButton.setVisible(false);
        orderButton.setVisible(false);

        //组件设置

        loginView.setImage(new Image("file:PaiMengShop/PaiMengShopClient/src/main/resources/com/example/paimengshop/controllerImage/loginButton.png"));

        //鼠标点击事件
        loginView.setOnMouseClicked(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent mouseEvent) {

                //点击跳转登录界面
                Stage oldStage=(Stage) loginView.getScene().getWindow();

                FXMLLoader fxmlLoader=new FXMLLoader(this.getClass().getResource("Account-View.fxml"));


                Scene scene= null;
                try {
                    scene = new Scene(fxmlLoader.load(),880,666);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }

                 main.setAccountController(fxmlLoader.getController());

                Stage newStage=new Stage();
                newStage.setTitle("派蒙的周边商铺");
                newStage.setScene(scene);

                newStage.initStyle(StageStyle.TRANSPARENT);
                scene.setFill(null);
                oldStage.close();
                newStage.show();


                //测试用，直接跳过登录状态
                /*Stage oldStage=(Stage) loginView.getScene().getWindow();

                FXMLLoader fxmlLoader=new FXMLLoader(this.getClass().getResource("main.fxml"));

                Scene scene= null;
                try {
                    scene = new Scene(fxmlLoader.load());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }

                Stage newStage=new Stage();
                newStage.setTitle("派蒙的周边商铺");
                newStage.setScene(scene);

                oldStage.close();
                newStage.show();*/
            }
        });
    }
}
